import Vue from 'vue'
import VueRouter from 'vue-router'
import Main from '../views/Main.vue'

//路由导航冗余报错（路由重复）
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


Vue.use(VueRouter)

const routes = [
  {
    path: "/main",
    name: 'Main',
    component: Main,
/*    redirect:'/home',  /!*当访问主页的时候，自动加载Home组件（路由的自动跳转）*!/*/
    children:[
      {
        path:'user',
        name:"User",
        component: () => import("@/views/User")  /*第二种方式加载组件：懒加载，在路由中加载组件（嵌套路由）*/
      },
      {
        path:"bvp",
        name:'Bvp',
        component: () => import("@/views/Bvp")
      },
      {
        path:"permission",
        name: "Permission",
        component: () => import("@/views/Permission")
      },
      {
        path:"blog",
        name: "Blog",
        component: () => import("@/views/Blog")
      },
      {
        path:"leaveMessage",
        name: "LeaveMessage",
        component: () => import("@/views/LeaveMessage")
      },
      {
        path:"personalDetails",
        name:"PersonalDetails",
        component:() => import("@/views/PersonalDetails")
      },
      {
        path: "news",
        name:"News",
        component:() => import("@/views/News"),
      },
      {
        path:"newsRelease",
        name:"NewsRelease",
        component:() => import("@/views/NewsRelease")
      }
    ]
  },
  {
    path:"/",
    name:"login",
    component: () => import("@/views/Login")
  },
  {
    path:"/login",
    name:"login",
    component: () => import("@/views/Login")
  },
  {
    path:"/register",
    name:"register",
    component: () => import("@/views/Register")
  },


]

const router = new VueRouter({
  mode:"history",  /*去掉路由井号*/
  routes,
})

export default router
